/**
 * Created by zixinhmc on 2016/9/10.
 */
console.log('----------------------------')
console.log('test4')

function createArray(...elements){
    let handler = {
        get(target, propKey, reciver){
            console.log(target);
            console.log(propKey);

            let index = Number(propKey);
            if(index < 0){
                propKey = String(target.length + index)
            }
            return Reflect.get(target, propKey, reciver);
        }
    }

    let target = [];
    target.push(...elements);
    return new Proxy(target, handler)
}

let arr = createArray('a', 'b', 'c')
console.log(arr[-1])


